package com.zt.action.sys;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.zt.action.base.BaseAction;
import com.zt.model.sys.Sample;
import com.zt.service.sys.ISampleService;

/**
 * Action 类 SampleAction
 * 
 * @author zhangzhw
 * @describe Sample Action
 */
public class SampleAction extends BaseAction {

	// 注入值
	private ISampleService iSampleService;

	// 返回值
	public List<Sample> sampleList;

	public boolean success = true;

	// Action 参数
	public long sampleId;
	public String sampleName;
	public Timestamp sampleDate;

	/**
	 * Action 方法 findSample
	 * 
	 * @return SUCCESS
	 * @throws Exception
	 * @describe 查询Sample 的方法
	 */
	public String findSample() throws Exception {

		sampleList = iSampleService.findSample();

		return SUCCESS;
	}

	/**
	 * Action 方法 saveSample
	 * 
	 * @return SUCCESS
	 * @throws Exception
	 * @describe 保存Sample的Action 方法
	 */
	public String saveSample() throws Exception {
		Sample s = new Sample();

		s.setSampleId(sampleId);
		s.setSampleName(sampleName);
		s.setSampleDate(sampleDate);

		iSampleService.save(s);

		return SUCCESS;

	}

	/**
	 * Action 方法 deleteSample
	 * 
	 * @return SUCCESS
	 * @throws Exception
	 * @describe 删除Sample的Action 方法
	 */
	public String deleteSample() throws Exception {
		Sample s = new Sample();

		s.setSampleId(sampleId);

		iSampleService.delete(s);
		return SUCCESS;
	}

	// getters and setters

	@JSON(serialize = false)
	// 不进
	public ISampleService getiSampleService() {
		return iSampleService;
	}

	public void setiSampleService(ISampleService iSampleService) {
		this.iSampleService = iSampleService;
	}

	public List<Sample> getSampleList() {
		return sampleList;
	}

	public void setSampleList(List<Sample> sampleList) {
		this.sampleList = sampleList;
	}

	public long getSampleId() {
		return sampleId;
	}

	public void setSampleId(long sampleId) {
		this.sampleId = sampleId;
	}

	public String getSampleName() {
		return sampleName;
	}

	public void setSampleName(String sampleName) {
		this.sampleName = sampleName;
	}

	public Timestamp getSampleDate() {
		return sampleDate;
	}

	public void setSampleDate(Timestamp sampleDate) {
		this.sampleDate = sampleDate;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

}
